<script>
</script>

<template>
  <div id="app">
    <div class="content">
      <div class="top w">
        <span>当前位置：</span>
        <a href="#">首页 ></a>
        <a href="#">社区 ></a>
        <span> 作品</span>
      </div>
      <div :class="[flag ? 'navBox' : '']">
        <div class="nav w">
          <router-link class="zuopin" to="/community/zuopin">作品</router-link>
          <router-link class="btn" to="/fabu">
            <span class="iconfont icon-zhifeiji"></span
            ><span>发布</span></router-link
          >
        </div>
      </div>
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
import "@/assets/font/iconfont.css";
export default {
  data() {
    return {
      flag: false,
    };
  },
  mounted() {
    window.addEventListener("scroll", this.handleScrollx, true);
  },
  methods: {
    handleScrollx() {
      var scrollTop =
        window.pageYOffset ||
        document.documentElement.scrollTop ||
        document.body.scrollTop;
      if (scrollTop >= 60) {
        this.flag = true;
      } else {
        this.flag = false;
      }
    },
  },
  beforeDestroy() {
    window.removeEventListener("scroll", this.handleScrollx);
  },
};
</script>

<style scoped="scoped" lang="scss">
a {
  text-decoration: none;
}
.w {
  width: 1180px;
  margin: 0 auto;
}
.top {
  display: flex;
  justify-content: flex-start;
  /* align-items: center; */
  padding-top: 10px;
  box-sizing: border-box;
  height: 60px;
  font-size: 14px;
  color: #87959f;
  a {
    color: #87959f;
    font-size: 14px;
  }
}
.navBox {
  width: 100%;
  position: fixed;
  top: 60px;
  left: 0;
  background-color: #fff;
  z-index: 20;
}
.nav {
  height: 70px;
  background-color: #fff;
  display: flex;
  justify-content: space-between;
  padding-top: 20px;
  box-sizing: border-box;
}
.zuopin {
  height: 40px;
  text-align: center;
  line-height: 50px;
  color: #027cdb;
  border-bottom: 3px solid #027cdb;
}
.btn {
  width: 110px;
  height: 40px;
  background-color: #027cdb;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.icon-zhifeiji {
  font-size: 26px;
  margin-right: 5px;
}
.btn:hover {
  background-color: #73b2fc;
  cursor: pointer;
}
</style>